package com.example.bms.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.bms.entity.Score;
import com.example.bms.mapper.ScoreMapper;
import com.example.bms.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;


@Service
@Transactional

public class ScoreServiceImpl implements ScoreService {

    @Autowired
    private ScoreMapper scoreMapper;
    /**
     * @apiNote 插入一条成绩
     * @param score 成绩记录
     * @author
     * @email 1627856348@qq.com
     * @return int类型，插入成功返回1，插入失败返回0
     * @since 1.0.0
     */
    @Override
    public int add(Score score) {
        return scoreMapper.add(score);
    }

    /**
     * @apiNote 查询所有学生成绩
     * @author
     * @email 1627856348@qq.com
     * @return List<Score>
     * @since 1.0.0
     */
    @Override
    public List<Score> findAll() {
        return scoreMapper.findAll();
    }

    /**
     * @apiNote 查询所有学生成绩
     * @author
     * @param page 分页
     * @param studentId 学生id
     * @email 1627856348@qq.com
     * @return IPage<Score>
     * @since 1.0.0
     */
    @Override
    public IPage<Score> findById(Page page, Integer studentId) {
        return scoreMapper.findByIdPage(page, studentId);
    }
    /**
     * @apiNote 根据学生id查成绩
     * @param studentId 学生id
     * @author
     * @email 1627856348@qq.com
     * @return List<Score>
     * @since 1.0.0
     */
    public List<Score> findById(Integer studentId) {
        return scoreMapper.findById(studentId);
    }
    /**
     * @apiNote 查询每位同学的学科成绩
     * @author
     * @param examCode 考试编号
     * @email 1627856348@qq.com
     * @return  List<Score>
     * @since 1.0.0
     */
    @Override
    public List<Score> findByExamCode(Integer examCode) {
        return scoreMapper.findByExamCode(examCode);
    }
}
